<?php $paginator = $this->Paginator; ?>

<section id="Analyst">
    <div class="page-head">
        <div class="container">
            <div class="row">
                <div class="span9 head-text">
                    <h3><span><?php echo $broker['Broker']['fullname'] ?></span></h3>   
                    <p><?php echo $broker['Broker']['description'] ?></p>
                </div>
                <div class="span3">
                    <i class="icon icon-play-sign"></i>
                </div>						
            </div>
        </div>			
    </div>
    <div class="container">
        <div class="page-section">
            <div class="row">
                <div class="span12 aligncenter">

                    <?php
                    $text_display = '';
                    foreach ($rows as $row) :
                        $current_value = $previous_value = 0;
                        if ($row['Stock']['values']) {
                            $current_value = $row['Stock']['values'][0]['StockValues']['closing'];
                            if (isset($row['Stock']['values'][1])) {
                                $previous_value = $row['Stock']['values'][1]['StockValues']['closing'];
                            }

                            if ($row['Stock']['opinion']) {
                                if ($row['Stock']['opinion']['Opinion']['result'] == 1) {
                                    $text_display .='<div class="services-box services-bgcolor e_bounce">'
                                            . '<h5>' . $row['Stock']['name'] . '</h5>'
                                            . '<p>Curent Value = ' . $current_value . '<br>On ' . date('d/m/Y', strtotime($row['Stock']['values'][1]['StockValues']['date'])) . ' = ' . $previous_value . '<br></p>'
                                            . '<p>Previous Opinion<br><i style="color:#0C3;">True</i></p>'
                                            . $this->Html->link("View Profile", "/analyst/view/" . $broker["Broker"]["id"], array("class" => "btn btn-primary"))
                                            . '</div>';
                                } else {
                                    $text_display .='<div class="services-box services-bg1 e_bounce">'
                                            . '<h5>' . $row['Stock']['name'] . '</h5>'
                                            . '<p>Curent Value = ' . $current_value . '<br>On ' . date('d/m/Y', strtotime($row['Stock']['values'][1]['StockValues']['date'])) . ' = ' . $previous_value . '<br></p>'
                                            . '<p>Previous Opinion<br><i style="color:#C33;">Wrong</i></p>'
                                            . $this->Html->link("View Profile", "/analyst/view/" . $broker["Broker"]["id"], array("class" => "btn btn-primary"))
                                            . '</div>';
                                }
                            } else {
                                $text_display .='<div class="services-box services-bg1 e_bounce">'
                                        . '<h5>' . $row['Stock']['name'] . '</h5>'
                                        . '<p>Curent Value = ' . $current_value . '<br>On ' . date('d/m/Y', strtotime($row['Stock']['values'][1]['StockValues']['date'])) . ' = ' . $previous_value . '<br></p>'
                                        . '<p>Previous Opinion<br><i style="color:#fff;">-</i></p>'
                                        . $this->Html->link("View Profile", "/analyst/view/" . $broker["Broker"]["id"], array("class" => "btn btn-primary"))
                                        . '</div>';
                            }
                            
                        } else {
                            $text_display .='<div class="services-box services-bg1 e_bounce">'
                                    . '<h5>' . $row['Stock']['name'] . '</h5>'
                                    . '<p>&nbsp;</p>'
                                    . $this->Html->link("View Profile", "/analyst/view/" . $broker["Broker"]["id"], array("class" => "btn btn-primary"))
                                    . '</div>';
                        }

                    endforeach;
                    ?>


                    <?php echo $text_display; ?>      

                    <div class="span12 pagination">
                        &nbsp;
                        <ul>
                            <?php
                            if ($paginator->hasPrev()) {
                                echo '<li>' . $paginator->prev("Prev") . '</li>';
                            }
                            ?>
                            <?php echo $paginator->numbers(array('modulus' => 3, 'tag' => 'li', 'separator' => '', 'currentTag' => 'a', 'currentClass' => 'active')); ?>
                            <?php
                            if ($paginator->hasNext()) {
                                echo '<li>' . $paginator->next("Next") . '</li>';
                            }
                            ?>
                        </ul>
                    </div>
                </div>

            </div>
        </div>
    </div>
</section>